package com.asm.controller.api;

import com.asm.dto.PageResult;
import com.asm.dto.Result;
import com.asm.service.ContractContainService;
import com.asm.vo.sys.ContractContainVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


/**
 * @author tanzujie
 */
@RestController
public class ContractContainController {
    @Autowired
    private ContractContainService contractcontainService;

    /**
     * 分页查询所有合同包含
     *
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/contractcontains")
    public ResponseEntity<PageResult<ContractContainVo>> getAllContractContains(Integer pageNumber, Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findAllContractContains(pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 根据Id获取合同包含
     *
     * @param id
     * @return
     */
    @GetMapping("/contractcontain/{id}")
    public ResponseEntity<Result<ContractContainVo>> getContractContainById(@PathVariable("id") Long id) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainById(id)), HttpStatus.OK);
    }

    /**
     * 根据合同编号分页查询编号合同包含
     *
     * @param contractid
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/contractcontains/contractid/{contractid}")
    public ResponseEntity<PageResult<ContractContainVo>> getContractContainByContractId(@PathVariable("contractid") Long contractid, Integer pageNumber, Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainByContractId(contractid, pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 根据广告位编号分页查询合同包含
     *
     * @param spotid
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @GetMapping("/contractcontains/spotid/{spotid}")
    public ResponseEntity<PageResult<ContractContainVo>> getContractContainBySpotId(@PathVariable("spotid") Long spotid, Integer pageNumber, Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainBySpotId(spotid, pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 增加合同包含
     *
     * @param contractcontainVo
     * @return
     */
    @PostMapping("/contractcontain/add")
    public ResponseEntity<Result> addContractContain(@RequestBody ContractContainVo contractcontainVo) {
        contractcontainService.addContractContain(contractcontainVo);
        return new ResponseEntity(new Result().ok("add success"), HttpStatus.OK);
    }

    /**
     * 更新合同包含
     *
     * @param contractcontainVo
     * @return
     */
    @PutMapping("/contractcontain/update")
    public ResponseEntity<Result> updateContractContain(@RequestBody ContractContainVo contractcontainVo) {
        contractcontainService.updateContractContain(contractcontainVo);
        return new ResponseEntity(new Result().ok("update success"), HttpStatus.OK);
    }

    /**
     * 根据Id删除合同包含
     *
     * @param id
     * @return
     */
    @DeleteMapping("/contractcontain/delete/{id}")
    public ResponseEntity<Result> deleteContractContain(@PathVariable("id") Long id) {
        contractcontainService.deleteContractContain(id);
        return new ResponseEntity(new Result().ok("delete success"), HttpStatus.OK);
    }
}
